function dQ = GetdQ_ECC(wm)

ss = size(wm,1);

if ss == 2
    t1=wm(1,:)';  t2=wm(2,:)';
    phi = t1 + t2 + 2/3*cross(t1,t2);
elseif ss == 3
    t1=wm(1,:)';  t2=wm(2,:)';  t3=wm(3,:)';
    phi = t1 + t2 + t3 + 27/40*cross(t1,t2) + 9/20*cross(t1,t3)  + 27/40*cross(t2,t3);
elseif ss == 4
    t1=wm(1,:)';  t2=wm(2,:)';  t3=wm(3,:)';  t4=wm(4,:)';
    phi = t1 + t2 + t3 + t4 ...
          + 232/315*cross(t3,t4) + 46/105*cross(t2,t4) ...
          + 18/35*cross(t1,t4)   + 178/315*cross(t2,t3) ...
          + 46/105*cross(t1,t3)  + 232/315*cross(t1,t2);
elseif ss == 5
    t1=wm(1,:)';  t2=wm(2,:)';  t3=wm(3,:)';  t4=wm(4,:)';  t5=wm(5,:)';
    phi = t1 + t2 + t3 + t4 + t5 ...
          + 18575/24192*cross(t4,t5) + 2675/6048*cross(t3,t5) + 11225/24192*cross(t2,t5) ...
          + 125/252*cross(t1,t5) + 2575/6048*cross(t3,t4) + 425/672*cross(t2,t4) ...
          + 13975/24192*cross(t1,t4)   + 1975/3024*cross(t2,t3) ...
          + 325/1512*cross(t1,t3)  + 21325/34192*cross(t1,t2);
end

dQ = rv2q(phi);

end